home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / pm-utils / sleep.d / 55NetworkManager < prev    next >
Encoding:
Text File  |  2009-04-07  |  1.0 KB  |  39 lines

  1. #!/bin/sh
  2. # If we are running NetworkManager, tell it we are going to sleep.
  3. # TODO: Make NetworkManager smarter about how to handle sleep/resume
  4. #       If we are asleep for less time than it takes for TCP to reset a
  5. #       connection, and we are assigned the same IP on resume, we should
  6. #       not break established connections.  Apple can do this, and it is
  7. #       rather nifty.
  8.  
  9. . "${PM_FUNCTIONS}"
  10.  
  11. suspend_nm()
  12. {
  13.     # Tell NetworkManager to shut down networking
  14.     dbus_send --print-reply --system                         \
  15.         --dest=org.freedesktop.NetworkManager  \
  16.         /org/freedesktop/NetworkManager        \
  17.         org.freedesktop.NetworkManager.sleep 2>&1 > /dev/null
  18. }
  19.  
  20. resume_nm()
  21. {
  22.     # Wake up NetworkManager and make it do a new connection
  23.     dbus_send --print-reply --system                        \
  24.         --dest=org.freedesktop.NetworkManager \
  25.         /org/freedesktop/NetworkManager       \
  26.         org.freedesktop.NetworkManager.wake 2>&1 > /dev/null
  27. }
  28.  
  29. case "$1" in
  30.     hibernate|suspend)
  31.         suspend_nm
  32.         ;;
  33.     thaw|resume)
  34.         resume_nm
  35.         ;;
  36.     *) exit $NA
  37.         ;;
  38. esac
  39.